<template>
  <div v-if="result.total > 0">
    <MyFollowedDisplayComponent
      v-for="(item, index) in result.records"
      :key="index"
      :user="item"
    />

    <div class="pagination">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="result.total"
        :page-size="result.size"
        @current-change="getFollowedInfo"
      />
    </div>
  </div>
  <div v-else>
    <NoFollowsComponent />
  </div>
</template>

<script>
import { getMyFollowersInfo } from "@/api/userCenter";
import MyFollowedDisplayComponent from "@/components/MyFollowedDisplayComponent.vue";
import NoFollowsComponent from "@/components/NoFollowsComponent.vue";

export default {
  components: { MyFollowedDisplayComponent, NoFollowsComponent },
  data() {
    return {
      userList: [],
      userId: "",
      result: {},
      page: 1,
      size: 4,
    };
  },
  created() {
    this.userId = this.$route.params.id;
    this.getFollowedInfo(1);
  },
  methods: {
    async getFollowedInfo(page) {
      this.page = page;
      const res = await getMyFollowersInfo(this.page, this.size, this.userId);
      if (res.data.success) {
        this.result = res.data.result;
      }
    },
  },
};
</script>

<style>
</style>